package Text3;

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
//        给定一个长度为 n 的整数数列，请你计算数列中的逆序对的数量。
        int n = scanner.nextInt();
        int[] q = new int[n];
        for (int i = 0; i < q.length; i++) {
            q[i] = scanner.nextInt();
        }

        System.out.println( func(q, 0, n - 1));
    }

    private static long func(int[] q, int l, int r) {
        if(l>=r){
          return 0;
        }
        int mid=l+r>>1;
        long count=func(q, l,mid) +func(q,mid+1,r);
        int k=0,i=l,j=mid+1;
        int[] tmp=new int[r-l+1];
        while(i<=mid&&j<=r){
            if(q[i]<=q[j]){
                tmp[k++]=q[i++];
            }else{
                tmp[k++]=q[j++];
                count+=mid-i+1;
            }
        }
        while(i<=mid){
            tmp[k++]=q[i++];
        }
        while(j<=r){
            tmp[k++]=q[j++];
        }

        for (int m = 0; m < tmp.length; m++) {
            q[m+l]=tmp[m];
        }
        return count;
    }
}
